Skip to content

gh-119180: Avoid going through AST and eval() when possible in annotationlib#124337

Merged
JelleZijlstra merged 11 commits intopython:mainfrom
JelleZijlstra:pep649-optanno
Sep 25, 2024
Merged

gh-119180: Avoid going through AST and eval() when possible in annotationlib#124337
JelleZijlstra merged 11 commits intopython:mainfrom
JelleZijlstra:pep649-optanno

Conversation

@JelleZijlstra
Copy link
Member

@JelleZijlstra JelleZijlstra commented Sep 23, 2024

Often, ForwardRefs represent a single simple name. In that case, we can avoid going through the overhead of creating AST nodes and code objects and calling eval(): we can simply look up the name directly in the relevant namespaces.

This PR incorporates the changes from #124326 (which fixes a bug that I discovered while working on this change).

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants